package com.example.blogdemo1.controller;

/*
 * @author zzr
 * @date: 2025/10/05  21:01
 * @description:
 */

import com.example.blogdemo1.common.model.Result;
import com.example.blogdemo1.common.model.UserInfo;
import com.example.blogdemo1.common.utils.SecurityUtils;
import com.example.blogdemo1.service.UserService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/login")
    public Result login (String username,String password) {
        log.info("用户登录,username:{}",username);
        return userService.login(username,password);
    }

    @RequestMapping("/getUserInfo")
    public UserInfo getUserInfo(HttpServletRequest request) {
        return userService.getUserInfo(request);
    }

    @RequestMapping("/getAuthorInfo")
    public UserInfo getAuthorInfo(Integer blogId) {
        return userService.selectAuthorInfoByBlogId(blogId);
    }
}
